#include <iostream>

using namespace std;

class Solution {
public:
    int rangeBitwiseAnd(int m, int n) {
        uint32_t n1, n2;
        n1 = m;
        n2 = n;
        int bit_position = 31;
        for (; bit_position >= 0; bit_position--) {
            int s1 = n1 & 0x80000000;
            int s2 = n2 & 0x80000000;
            if (s1 != s2) {
                break;
            }
            n1 <<= 1;
            n2 <<= 1;
        }
        return ((uint32_t) m) >> (bit_position + 1) << (bit_position + 1) ;
    }
};

int main() {
    Solution solution;
    int output = solution.rangeBitwiseAnd(5, 7);
    cout << output << endl;
    return 0;
}